package com.educationx;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CourseListArrayAdapter extends ArrayAdapter<Course> {
	private Context context;
	private List<Course> items;

	public CourseListArrayAdapter(Context context, int textViewResourceId, List<Course> items) {
		super(context, textViewResourceId, items);
		this.context = context;
		this.items = items;
	}
	
	

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.row_main, parent, false);
		}
		final String item = items.get(position).getName();
		if (item != null) {
			TextView tw1 = (TextView) v.findViewById(R.id.textViewCourse);
			if (tw1 != null) {
				tw1.setText(item);                            
			}
		}
		return v;
	}
}
